import { createSlice } from '@reduxjs/toolkit'

const initialState =  {
	isLogin: false,
	id: '',
	nickname: '',
	avator: '',
	token: ''
}

const userSlice = createSlice({
	name: 'user',
	initialState,
	reducers: {
		loginSuccess(state, action) {
			state.isLogin = true;
			state.id = action.payload.id
			state.nickname = action.payload.nickname
			state.avator = action.payload.avator
			state.token = action.payload.token
		}
	}
})

export default userSlice.reducer
export const { loginSuccess } = userSlice.actions